package com.ruoyi.cderp.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.cderp.domain.SettleInItem;
import com.ruoyi.cderp.service.ISettleInItemService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 收入项目Controller
 * 
 * @author ruoyi
 * @date 2025-03-04
 */
@RestController
@RequestMapping("/system/SettleInItem")
public class SettleInItemController extends BaseController
{
    @Autowired
    private ISettleInItemService settleInItemService;

    /**
     * 查询收入项目列表
     */
    @PreAuthorize("@ss.hasPermi('system:SettleInItem:list')")
    @GetMapping("/list")
    public TableDataInfo list(SettleInItem settleInItem)
    {
        startPage();
        List<SettleInItem> list = settleInItemService.selectSettleInItemList(settleInItem);
        return getDataTable(list);
    }

    /**
     * 导出收入项目列表
     */
    @PreAuthorize("@ss.hasPermi('system:SettleInItem:export')")
    @Log(title = "收入项目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SettleInItem settleInItem)
    {
        List<SettleInItem> list = settleInItemService.selectSettleInItemList(settleInItem);
        ExcelUtil<SettleInItem> util = new ExcelUtil<SettleInItem>(SettleInItem.class);
        util.exportExcel(response, list, "收入项目数据");
    }

    /**
     * 获取收入项目详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:SettleInItem:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(settleInItemService.selectSettleInItemById(id));
    }

    /**
     * 新增收入项目
     */
    @PreAuthorize("@ss.hasPermi('system:SettleInItem:add')")
    @Log(title = "收入项目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SettleInItem settleInItem)
    {
        return toAjax(settleInItemService.insertSettleInItem(settleInItem));
    }

    /**
     * 修改收入项目
     */
    @PreAuthorize("@ss.hasPermi('system:SettleInItem:edit')")
    @Log(title = "收入项目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SettleInItem settleInItem)
    {
        return toAjax(settleInItemService.updateSettleInItem(settleInItem));
    }

    /**
     * 删除收入项目
     */
    @PreAuthorize("@ss.hasPermi('system:SettleInItem:remove')")
    @Log(title = "收入项目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(settleInItemService.deleteSettleInItemByIds(ids));
    }
}
